$(document).ready(function () {
    $("#table").bootstrapTable({
        url:"/recordList",  //请求地址
        striped : true, //是否显示行间隔色
        pageNumber : 1, //初始化加载第一页
        pagination : true,//是否分页
        sidePagination : 'server',//server:服务器端分页|client：前端分页
        pageSize : 10,//单页记录数
        pageList : [ 5, 10, 20],//可选择单页记录数
        undefinedText: "数据为空",
        search : true,
        searchOnEnterKey : true,
        showToggle: true,//是否显示切换试图（table/card）按钮
        showColumns: true,
        showRefresh : true,//刷新按钮
        paginationPreText: "<<",
        paginationNextText: ">>",
        queryParams : function(params) {
            var temp = {
                offset : params.offset + 0,
                pageNumber: params.limit
            };
            return temp;
        },
        columns : [ {
            title : '任务编号',
            field : 'recordId',
        },{
            title : '提交时间',
            field : 'addTime',
            sortable: true,
        }, {
            title : '操作时间',
            field : 'doneTime',
            sortable: true,
        }, {
            title: '状态',
            field: 'stateStr',
        }, {
            field: 'Button',
            title: '操作',
            valign: 'middle',
            align: 'center',
            formatter: addFunctionAlty,
        }]
    })
})

function addFunctionAlty(value,row,index) {
    if (row.state == 4) {
        return[
            '<button onClick="verify(\'' + row.sliceStr + '\')" type="button" class="btn btn-outline-success">审核</button>'
        ].join("")
    }else if (row.state == 5) {
        return[
            '<button onClick="verify(\'' + row.sliceStr + '\')" type="button" class="btn btn-outline-success">查看</button>'
            + '&nbsp;' +
            '<button onClick="modify(\'' + row.taskStr + '\')" type="button" class="btn btn-outline-primary" style="margin-left: 5dp">修改</button>'
        ].join("")
    }

}

function verify(id) {
    window.open('/result?sliceId=' + id, '_blank');
}

function modify(id) {
    window.open('/modify?taskStr=' + id, '_blank');
}